<?php
/**
 * Data object model of radiology queue item
 *
 */
$loader->requireOnce('includes/RadQueue/RadTicketItemModel.class.php');
class RadQueueItemModel {
    private $rad_ticket_id;
    private $patient_id;
    private $patient_code;
    private $patient_name;
    private $start_waiting;
    private $waiting_time;
    private $treatment_department_id;
    private $treatment_department_name;
    private $item_list  =   array();

    function __construct($radTicketId, $patientId, $patientCode, $patientName,
            $startWaiting, $waitingTime, $deptId, $deptName) {
        $this->rad_ticket_id                =   $radTicketId;
        $this->patient_id                   =   $patientId;
        $this->patient_code                 =   $patientCode;
        $this->patient_name                 =   $patientName;
        $this->start_waiting                =   $startWaiting;
        $this->waiting_time                 =   $waitingTime;
        $this->treatment_department_id      =   $deptId;
        $this->treatment_department_name    =   $deptName;
        $this->buildItemList();
    }

    private function buildItemList() {
        $itemList   =   ORDataObject::factory('RadTicketItem')->getServicesByTicket($this->rad_ticket_id);
        foreach ($itemList as $item) {
            $itemModel  =   new RadTicketItemModel($this->rad_ticket_id, $item['service_id'], $item['name'], $item['is_done']);
            $this->item_list[]  =   $itemModel;
        }
    }

    public function getRadTicketId() {
    	return $this->rad_ticket_id;
    }

    public function getPatientCode() {
    	return $this->patient_code;
    }

    public function getPatientName() {
    	return $this->patient_name;
    }

    public function getStartWaiting() {
    	return $this->start_waiting;
    }

    public function getWaitingTime() {
    	return $this->waiting_time;
    }

    public function getTreatmentDepartmentId() {
    	return $this->treatment_department_id;
    }

    public function getTreatmentDepartmentName() {
        return $this->treatment_department_name;
    }

    public function getItemList() {
        return $this->item_list;
    }

    // General setter
    public function set($key, $value) {
        if(property_exists($this,$key)){
            $this->$key =   $value;
        }
    }

    // General getter
    public function get($key) {
        if(property_exists($this,$key)){
            return $this->$key;
        }
        return '';
    }
}
?>